<template>
  <div class="teacher-project-container">
    <el-card shadow="hover">
      <div class="header">
        <h2>项目申报管理</h2>
        <el-button type="primary" @click="onAdd" style="float:right;">新增项目</el-button>
      </div>
      <el-table :data="projects" stripe border style="width: 100%; margin-top: 20px;">
        <el-table-column prop="number" label="项目编号" width="120" />
        <el-table-column prop="name" label="项目名称" width="180" />
        <el-table-column prop="type" label="项目类型" width="120" />
        <el-table-column prop="status" label="状态" width="100" />
        <el-table-column label="操作" width="260">
          <template #default="scope">
            <el-button size="small" @click="onDetail(scope.row)" icon="el-icon-view">详情</el-button>
            <el-button size="small" type="primary" @click="onEdit(scope.row)" icon="el-icon-edit">编辑</el-button>
            <el-button size="small" type="danger" @click="onDelete(scope.row)" icon="el-icon-delete">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-dialog v-model="dialogVisible" :title="dialogTitle" width="500px">
      <el-form :model="form">
        <el-form-item label="项目编号"><el-input v-model="form.number" /></el-form-item>
        <el-form-item label="项目名称"><el-input v-model="form.name" /></el-form-item>
        <el-form-item label="项目类型"><el-input v-model="form.type" /></el-form-item>
        <el-form-item label="状态"><el-input v-model="form.status" /></el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="dialogVisible=false">取消</el-button>
        <el-button type="primary" @click="onSave">保存</el-button>
      </template>
    </el-dialog>
  </div>
</template>
<script setup>
import { ref } from 'vue';
const projects = ref([
  { number: 'P001', name: '创新项目1', type: '科技', status: '待审核' },
  { number: 'P002', name: '创新项目2', type: '社会', status: '已通过' },
]);
const dialogVisible = ref(false);
const dialogTitle = ref('');
const form = ref({});
function onAdd() { dialogTitle.value='新增项目'; form.value={}; dialogVisible.value=true; }
function onEdit(row) { dialogTitle.value='编辑项目'; form.value={...row}; dialogVisible.value=true; }
function onDetail(row) { dialogTitle.value='项目详情'; form.value={...row}; dialogVisible.value=true; }
function onDelete(row) { projects.value = projects.value.filter(p => p.number !== row.number); }
function onSave() { dialogVisible.value=false; }
</script>
<style scoped>
.teacher-project-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 0;
  background: #f5f7fa;
  min-height: 100vh;
}
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}
</style> 